<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body,
        html {
            background: linear-gradient(to right, #d3cce3, #e9e4f0);
            width:100%;
        }
        
        
        /* #tab {
            position: absolute;
            left: 50%;
            margin-left: -350px;
        } */
        .content-left{
            width: 800px;
            height: 2000px;
            margin: 100px auto;
           padding-left:50px;
            background: #F1F1F1;
            border-radius: 10px;
            box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
            overflow: hidden;
            position:absolute;
            left:4%; 
           
            */
        }
        .content-right{
            width: 500px;
            height: 2000px;
            margin: 100px auto;
           padding-left:15px;
            background: #F1F1F1;
            border-radius: 10px;
            box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
            overflow: hidden;
            position:absolute;
            left:60%; 
        }
        h2{
            text-align:center;
        }
       
        /* .add{
            width:90px;
            height:40px;
            padding:10px 20px;
            position:absolute;
            margin-left:-45px;
            margin-top:-20px;
            left:50%;
            top:30px;
            text-align:center;
            background:#4AB7BD;
            border-radius:6px;
            font-size:14px;
            color:#FFF;
        } */
        /* div.add{
            position:relative;
        } */
        .add-a{
            width:90px;
            height:40px;
            padding:10px 20px;
            position:absolute;
            margin-left:-45px;
            margin-top:-20px;
            left:50%;
            top:30px;
            text-align:center;
            background:#4AB7BD;
            border-radius:6px;
            font-size:14px;
            color:#FFF;
        }
        .add-a:hover{
            background:linear-gradient(to right, #7f00ff, #e100ff);
            transition:600ms;
            text-decoration:none;
            color:#FFF;
            
        }
        .delete-a:hover{
            background: linear-gradient(to right, #e44d26, #f16529);
            transition:600ms;
            text-decoration:none;
            color:#FFF;
        }
        .edit-a:hover{
            background:linear-gradient(to right, #f4c4f3, #fc67fa);
            transition:600ms;
            text-decoration:none;
            color:#FFF;
        }
        .delete-a{
            width:90px;
            height:40px;
            padding:10px 20px;
            position:absolute;
            margin-left:-45px;
            margin-top:-20px;
            left:50%;
            top:74px;
            text-align:center;
            background:#324157;
           border-radius:6px;
           font-size:14px;
           color:#FFF;
        }
        .edit-a{
            width:90px;
            height:40px;
            padding:10px 20px;
            position:absolute;
            margin-left:-45px;
            margin-top:-20px;
            left:50%;
            top:118px;
            text-align:center;
            background:#30B08F;
           border-radius:6px;
           font-size:14px;
           color:#FFF!important;
        }

       #th{
           height:30px !important;
           font-size:15px;
       }
       #tab{
            text-align:center;
            color: rgb(72, 72, 72);
            font-family: Circular, PingFang-SC, "Hiragino Sans GB", 微软雅黑, "Microsoft YaHei", "Heiti SC" !important;
            font-size: 16px ;
            line-height: 1.375em ;
            font-weight: 800 ;
       }
        #tab tr td{
            position:relative;
            height:140.8px;
            font-size:14px;
        }
        
       
    </style>
</head>

<body>
    <div class="conntainer">
        <div class="header">
            <h1 style="text-align: center">
                租房系统后台管理系统
            </h1>
        </div>
<!-- 租房房源信息管理 -->
        <div class="content-left">
            <h2>房源信息表</h2>
            <table id="tab" width="700px" border="1px">

                <tr id="th">
                    <th>id</th>
                    <th>房屋地址</th>
                    <th>房屋面积</th>
                    <th>楼层</th>
                    <th>租金</th>
                    <th>区域</th>
                    <th>类型</th>
                    <th>朝向</th>
                    <th>周围环境</th>
                    <th>装修情况</th>
                    <th>发布人</th>
                    <th>相关操作</th>
                </tr>

                <?php
  // 创建连接
$conn = mysql_connect("localhost:3306","root","wohenpi0918");
mysql_set_charset('utf8',$conn);
//编码，避免出现乱码
mysql_select_db("student",$conn);
//连接数据库

// 检测连接
if (!$conn) {
    die("Connection failed: " . mysql_connect_error());
}

$sql='SELECT * FROM rent ORDER BY id asc';
 // 结果集
 $result = mysql_query($sql,$conn) or die(mysql_error());

// 解析结果集,$row为rent表的所有数据，$Num为rent字段数目
  $Num=mysql_num_rows($result); 

  for($i=0; $i<$Num; $i++){
    $row = mysql_fetch_assoc($result);
    // 取出所有结果集
    echo "<tr>";
    echo "<td>{$row['id']}</td>";
    echo "<td>{$row['address']}</td>";
    echo "<td>{$row['proportion']}</td>";
    echo "<td>{$row['floor']}</td>";
    echo "<td>{$row['rentmoney']}</td>";
    echo "<td>{$row['area']}</td>";
    echo "<td>{$row['type']}</td>";
    echo "<td>{$row['direction']}</td>";
    echo "<td>{$row['surr']}</td>";
    echo "<td>{$row['decoration']}</td>";
    echo "<td>{$row['issuer']}</td>";
    echo "<td width='200px'>
            <div class='add'><a class='add-a' href='issue.php'>添加</a></div>
            <div class='delete'><a class='delete-a' href='javascript:del({$row['id']})'>删除<a></div>
            <div class='edit'><a class='edit-a' href='edit.php?id={$row['id']}'>修改</a></div>
          </td>";
    
    echo "</tr>";
}
//  增加： 首先设置的链接的地址为登录注册页面
//  删除 ： 用js函数传递id值并跳转页面  验证是否删除此条信息 true的话跳转到删除的delete.php(包含了连接数据库
// 的连接 通过id Delete掉这条信息 然后在里面写一个跳转到manger的href )
//  修改： 首先链接到edit.php（包含了连接数据库 取出了该条id的结果集 然后设置表单上的默认值都为结果集的每个字段
// 然后表单递交给 更新页面（包含了连接数据库 并且更新UPDATE这条结果集 跳转到manger ））


?>
            </table>
        </div>
<!-- 用户信息数据管理 -->
         <div class="content-right">
            <h2>用户信息管理</h2>
            <table id="tab" width="480px" border="1px">

                <tr id="th">
                    <th>用户名称</th>
                    <th>身份证号</th>
                    <th>电话号码</th>
                    <th>邮箱地址</th>
                    <th>相关操作</th>
                </tr>

                <?php
  // 创建连接
$conn = mysql_connect("localhost:3306","root","wohenpi0918");
mysql_set_charset('utf8',$conn);
//编码，避免出现乱码
mysql_select_db("student",$conn);
//连接数据库

// 检测连接
if (!$conn) {
    die("Connection failed: " . mysql_connect_error());
}

$sql='SELECT * FROM user';
 // 结果集
 $result = mysql_query($sql,$conn) or die(mysql_error());

// 解析结果集,$row为rent表的所有数据，$Num为rent字段数目
  $Num=mysql_num_rows($result); 

  for($i=0; $i<$Num; $i++){
    $row = mysql_fetch_assoc($result);
    // 取出所有结果集
    echo "<tr>";
    echo "<td>{$row['username']}</td>";
    echo "<td>{$row['idnum']}</td>";
    echo "<td>{$row['phone']}</td>";
    echo "<td>{$row['email']}</td>";
    echo "<td width='100px'>
    <div class='add'><a class='add-a' href='login.php'>添加</a></div>
    <div class='delete'><a class='delete-a' href='javascript:delu({$row['idnum']})'>删除<a></div>
    <div class='edit'><a class='edit-a' href='edituser.php?idnum={$row['idnum']}' >修改</a></div>
          </td>";
    echo "</tr>";
}
?>

            </table>
        </div>




       

    </div>
    
<script type="text/javascript">
function del(id){
    if(confirm("确认要删除此条信息吗"))
    {
        window.location.href="delete.php?id="+id;
    }
}
function delu(idnum){
    if(confirm("确认删除此条信息吗")){
        window.location.href="deleteuser.php?idnum="+idnum;
    }
}
    </script>
</body>

</html>